package saxion.speelveld.spaceengineer.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class TradePlanetsDB extends SQLiteOpenHelper
{

	public static final String TABLE_NAME = "tradeplanet";

	public static final String COLUMN_ID = "_id";

	public static final String COLUMN_GAMEID = "game_id";

	public static final String COLUMN_PLANETNAME = "planet_name";

	public static final String COLUMN_PLANETIMAGE = "planet_image";

	private static final String DATABASE_FILENAME = "tradeplanets.db";

	private static int DATABASE_VERSION = 1;

	public TradePlanetsDB(Context context)
	{
		super(context, DATABASE_FILENAME, null, DATABASE_VERSION);
	}

	public TradePlanetsDB(Context context, String name, CursorFactory factory,
		int version)
	{
		super(context, name, factory, version);
	}

	@Override
	public void onCreate(SQLiteDatabase db)
	{
		Log.w("TradePlanetsDB.onCreate", "Trade planets DB created");
		db.execSQL("create table " + TABLE_NAME +
			"(" + COLUMN_ID + " integer primary key autoincrement, "
			+ COLUMN_GAMEID + " integer not null , "
			+ COLUMN_PLANETIMAGE + " integer not null , "
			+ COLUMN_PLANETNAME + " integer not null);");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
	{
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
		onCreate(db);
	}

}